package com.scoring.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scoring.system.mapper.StudentMapper;
import com.scoring.system.pojo.Student;
import com.scoring.system.service.StudentService;
@Service("stduentService")
public class StudentServiceImpl implements StudentService {
	
	@Resource
	private StudentMapper studentDao;

	@Override
	public int softDeleteStudent(int studentId) {
		return studentDao.softDelete(studentId);
	}

	@Override
	public int saveStudent(Student record) {
		return studentDao.insert(record);
	}

	@Override
	public boolean canStudentLogin(String studentNumber, String password) {
		Student student=studentDao.selectByStudentNumberAndPassword(studentNumber, password);
		if(student!=null){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean isStudentExisted(String studentNumber) {
		return studentDao.selectByStudentNumber(studentNumber)!=null;
	}

	@Override
	public Student getStudentByStudentNumber(String studentNumber) {
		return studentDao.selectByStudentNumber(studentNumber);
	}

	@Override
	public Student getStudentById(int id) {
		return studentDao.selectByPrimaryKey(id);
	}

	@Override
	public Student getStudentByName(String name) {
		return studentDao.selectByName(name);
	}

	@Override
	public List<Student> listStudentByClassId(int classId) {
		return studentDao.ListStudentByClassId(classId);
	}

	@Override
	public int updateStudent(Student record) {
		return studentDao.updateByPrimaryKeySelective(record);
	}

}
